package com.diviner.jsontransform.enums;

public enum TitleEnum {
    Tags(0,"模块"),
    Path(1,"URL"),
    Method(2,"请求方式"),
    Summary(3,"api名称"),
    Description(4,"备注"),
    Content_Type(5,"content_type"),
    Parameters(6,"请求参数");
    private Integer code;
    private String title;

    public Integer getCode() {
        return code;
    }

    public String getTitle() {
        return title;
    }

    TitleEnum(Integer code, String title) {
        this.code = code;
        this.title = title;
    }

    /**
     * 根据code获取title
     * @param code
     * @return
     */
    public static String getTitle(Integer code) {
        if (code == null) return null;
        for (TitleEnum titleEnum : TitleEnum.values()) {
            if (code==titleEnum.getCode()) return titleEnum.getTitle();
        }
        return null;
    }

    /**
     * 更具title获取code
     * @param title
     * @return
     */
    public static Integer getCode(String title) {
        if (title == null) return null;
        for (TitleEnum titleEnum : TitleEnum.values()) {
            if (title.equals(titleEnum.getTitle())) return titleEnum.getCode();
        }
        return null;
    }
}
